#-----------------------------------------------------------------------------
# Configuration file for the Public Library for Ultrasound (PLUS) toolkit
#
# © Copyright 2016 The Laboratory for Percutaneous Surgery, Queen's University, Canada
#
# This file can be passed to a CMake FIND_PACKAGE call with the following syntax:
#
# FIND_PACKAGE(PlusLib @PLUSLIB_VERSION@ <REQUIRED|QUIET> <NO_MODULE>)
#   If NO_MODULE is included, set the variable PlusLib_DIR:PATH=@CMAKE_BINARY_DIR@
# 
# Once successful, you can either use the USE_FILE approach by the following CMake command:
# INCLUDE(${PLUS_USE_FILE})
#
# Or you can use the following variables to configure your CMake project:
#  PlusLib_INCLUDE_DIRS - include directories for Plus headers
#  PlusLib_LIBRARIES - list of CMake targets produced by this build of Plus
#  PlusLib_DATA_DIR - directory containing data collector configuration files, sample images, and 3d models
#-----------------------------------------------------------------------------

# set the targets file (relative for install location)
@PLUSLIB_CONFIG_CODE@
IF(VTK_FOUND)
  IF(NOT ${VTK_VERSION} VERSION_EQUAL "@VTK_VERSION@")
    MESSAGE(SEND_ERROR "Trying to use different VTK versions in PlusLib (@VTK_VERSION@) and your superceeding project (${VTK_VERSION}), use the same version of VTK.")
  ENDIF()
ELSE()
  SET(VTK_DIR "@VTK_CONFIG_DIR@" CACHE PATH "Path to VTK")
ENDIF()

FIND_PACKAGE(VTK "@VTK_VERSION@" EXACT REQUIRED NO_MODULE)
INCLUDE(${VTK_USE_FILE}) # Must be included as VTK does not populate CMake target properties correctly

IF(@ITK_FOUND@)
  IF(ITK_FOUND)
    IF(NOT ${ITK_VERSION} VERSION_EQUAL "@ITK_VERSION@")
      MESSAGE(SEND_ERROR "Trying to use different ITK versions in PlusLib (@ITK_VERSION@) and your superceeding project (${ITK_VERSION}), use the same version of ITK.")
    ENDIF()
  ELSE()
    SET(ITK_DIR "@ITK_CONFIG_DIR@" CACHE PATH "Path to ITK")
  ENDIF()
  FIND_PACKAGE(ITK "@ITK_VERSION@" EXACT REQUIRED NO_MODULE)
  INCLUDE(${ITK_USE_FILE}) # Must be included as ITK does not populate CMake target properties correctly
ENDIF()

IF(@IGSIO_FOUND@)
  IF(NOT DEFINED IGSIO_DIR)
    SET(IGSIO_DIR "@IGSIO_DIR@")
  ENDIF()
  FIND_PACKAGE(IGSIO NO_MODULE REQUIRED)
ENDIF()

SET(PLUSLIB_QT_COMPONENTS @PLUSLIB_QT_COMPONENTS@)
IF(PLUSLIB_QT_COMPONENTS) # guard against an empty list
  FIND_PACKAGE(Qt5 REQUIRED COMPONENTS @PLUSLIB_QT_COMPONENTS@)
ENDIF()

INCLUDE(${PlusLib_TARGETS_FILE})

# Tell the user project where to find our headers and libraries
SET(PlusLib_INCLUDE_DIRS "@PLUSLIB_INCLUDE_DIRS@")
SET(PlusLib_DATA_DIR "@PLUSLIB_DATA_DIR@")
SET(PlusLib_LIBRARIES "@PLUSLIB_DEPENDENCIES@")

# Tell the user project where to find Plus use file
SET(PlusLib_USE_FILE "@PLUSLIB_CONFIG_USEFILE@")

IF(@PLUS_USE_EPIPHAN@ AND NOT TARGET Epiphan)
  ADD_LIBRARY(Epiphan SHARED IMPORTED)
  SET_PROPERTY(TARGET Epiphan PROPERTY IMPORTED_IMPLIB "@EPIPHAN_LIB_DIR@/frmgrab@CMAKE_STATIC_LIBRARY_SUFFIX@")
  SET_PROPERTY(TARGET Epiphan PROPERTY IMPORTED_LOCATION "@EPIPHAN_BINARY_DIR@/frmgrab@CMAKE_SHARED_LIBRARY_SUFFIX@")
  LIST(APPEND PlusLib_LIBRARIES Epiphan)
ENDIF()

IF(@PLUS_USE_Ascension3DG@ AND NOT TARGET Ascension3DG)
  ADD_LIBRARY(Ascension3DG SHARED IMPORTED)
  SET_PROPERTY(TARGET Ascension3DG PROPERTY IMPORTED_IMPLIB "@Ascension3DG_LIB_FILE@")
  SET_PROPERTY(TARGET Ascension3DG PROPERTY IMPORTED_LOCATION "@Ascension3DG_SHARED_LIB_FILE@")
  LIST(APPEND PlusLib_LIBRARIES Ascension3DG)
ENDIF()

IF(@PLUS_USE_Ascension3DGm@ AND NOT TARGET Ascension3DGm)
  ADD_LIBRARY(Ascension3DGm SHARED IMPORTED)
  SET_PROPERTY(TARGET Ascension3DGm PROPERTY IMPORTED_IMPLIB "@ATC_MEDSAFE_LIB_DIR@/ATC3DGm@CMAKE_STATIC_LIBRARY_SUFFIX@")
  SET_PROPERTY(TARGET Ascension3DGm PROPERTY IMPORTED_LOCATION "@ATC_MEDSAFE_BINARY_DIR@/ATC3DGm@CMAKE_SHARED_LIBRARY_SUFFIX@")
  LIST(APPEND PlusLib_LIBRARIES Ascension3DGm)
ENDIF()

IF(@PLUS_USE_PHIDGET_SPATIAL_TRACKER@ AND NOT TARGET phidget)
  ADD_LIBRARY(phidget SHARED IMPORTED)
  SET_PROPERTY(TARGET phidget PROPERTY IMPORTED_IMPLIB "@PHIDGET_SPATIAL_LIB_DIR@/phidget22@CMAKE_STATIC_LIBRARY_SUFFIX@")
  SET_PROPERTY(TARGET phidget PROPERTY IMPORTED_LOCATION "@PHIDGET_SPATIAL_BINARY_DIR@/phidget22@CMAKE_SHARED_LIBRARY_SUFFIX@")
  LIST(APPEND PlusLib_LIBRARIES phidget)
ENDIF()

IF(@PLUS_USE_BRACHY_TRACKER@ AND NOT TARGET USDigitalEncoders)
  # should this be seperated out into BRACHY_TRACKER and USDigitalEncoders??
  # i.e. Options PLUS_USE_BRACHY_TRACKER and PLUS_USE_USDIGITALENCODERS_TRACKER
  ADD_LIBRARY(USDigitalEncoders SHARED IMPORTED)
  SET_PROPERTY(TARGET USDigitalEncoders PROPERTY IMPORTED_IMPLIB "@USDIGITAL_SEI_LIB_DIR@/SEIDrv32@CMAKE_STATIC_LIBRARY_SUFFIX@")
  SET_PROPERTY(TARGET USDigitalEncoders PROPERTY IMPORTED_LOCATION "@USDIGITAL_SEI_BINARY_DIR@/SEIDrv32@CMAKE_SHARED_LIBRARY_SUFFIX@")
  LIST(APPEND PlusLib_LIBRARIES USDigitalEncoders)
ENDIF()

IF(WIN32 AND @PLUS_USE_NVIDIA_DVP@ AND NOT TARGET NVidiaDVP)
  ADD_LIBRARY(NVidiaDVP SHARED IMPORTED)
  SET_PROPERTY(TARGET NVidiaDVP PROPERTY IMPORTED_IMPLIB "@NVIDIA_DVP_LIB_DIR@/dvp@CMAKE_STATIC_LIBRARY_SUFFIX@")
  SET_PROPERTY(TARGET NVidiaDVP PROPERTY IMPORTED_LOCATION "@NVIDIA_DVP_BINARY_DIR@/dvp@CMAKE_SHARED_LIBRARY_SUFFIX@")
  LIST(APPEND PlusLib_LIBRARIES NVidiaDVP)

  ADD_LIBRARY(QuadroSDI INTERFACE IMPORTED)
  SET_PROPERTY(TARGET QuadroSDI PROPERTY INTERFACE_INCLUDE_DIRECTORIES 
    "@QuadroSDI_INCLUDE_DIRS@"
    )
  IF((MSVC AND ${CMAKE_GENERATOR} MATCHES "Win64") OR NOT MSVC)
    SET_PROPERTY(TARGET QuadroSDI PROPERTY INTERFACE_LINK_LIBRARIES 
      "@QuadroSDI_LIBRARY_DIR@/nvapi64@CMAKE_STATIC_LIBRARY_SUFFIX@"
      "@QuadroSDI_LIBRARY_DIR@/ANCapi@CMAKE_STATIC_LIBRARY_SUFFIX@"
      "@QuadroSDI_LIBRARY_DIR@/NvCpl@CMAKE_STATIC_LIBRARY_SUFFIX@"
      "@QuadroSDI_LIBRARY_DIR@/cutil64@CMAKE_STATIC_LIBRARY_SUFFIX@"
      )
  ELSE()
    SET_PROPERTY(TARGET QuadroSDI PROPERTY INTERFACE_LINK_LIBRARIES 
      "@QuadroSDI_LIBRARY_DIR@/nvapi@CMAKE_STATIC_LIBRARY_SUFFIX@"
      "@QuadroSDI_LIBRARY_DIR@/ANCapi@CMAKE_STATIC_LIBRARY_SUFFIX@"
      "@QuadroSDI_LIBRARY_DIR@/NvCpl@CMAKE_STATIC_LIBRARY_SUFFIX@"
      "@QuadroSDI_LIBRARY_DIR@/cutil32@CMAKE_STATIC_LIBRARY_SUFFIX@"
      )
  ENDIF()
ENDIF()

IF(@PLUS_USE_AGILENT@)
  ADD_LIBRARY(AgilentMD1 SHARED IMPORTED)
  SET_TARGET_PROPERTIES(AgilentMD1 PROPERTIES
    IMPORTED_IMPLIB "@AgilentMD1_LIBRARY@"
    IMPORTED_LOCATION "@AgilentMD1_BINARY_DIR@/AgMD1Fundamental@PLATFORM_SUFFIX@@CMAKE_SHARED_LIBRARY_SUFFIX@"
    INTERFACE_INCLUDE_DIRECTORIES "@AgilentMD1_INCLUDE_DIR@"
    )
ENDIF()

IF(@PLUS_USE_BLACKMAGIC_DECKLINK@)
  SET(DECKLINK_SDK_ROOT "@DECKLINK_SDK_ROOT@")
  FIND_PACKAGE(DeckLinkSDK REQUIRED)
ENDIF()

IF(@PLUS_USE_OpenIGTLink@)
  IF(NOT DEFINED OpenIGTLinkIO_DIR)
    SET(OpenIGTLinkIO_DIR "@OpenIGTLinkIO_DIR@")
  ENDIF()
  FIND_PACKAGE(OpenIGTLinkIO NO_MODULE REQUIRED)
ENDIF()

IF(@PLUS_USE_OvrvisionPro@)
  SET(OvrvisionPro_DIR "@OvrvisionPro_DIR@")
  FIND_PACKAGE(OvrvisionPro REQUIRED NO_MODULE)
ENDIF()

IF(@PLUS_BUILD_WIDGETS@)
  SET(PLUSLIB_WIDGETS_QRC @PLUSLIB_WIDGETS_QRC@)
ENDIF()

IF(@PLUS_USE_NDI@)
  SET(ndicapi_DIR @ndicapi_DIR@)
  FIND_PACKAGE(ndicapi REQUIRED NO_MODULE)
ENDIF()

IF(@PLUS_USE_OpenCV@)
  SET(OpenCV_DIR @OpenCV_DIR@)
  FIND_PACKAGE(OpenCV NO_MODULE REQUIRED)
ENDIF()

IF(@PLUS_USE_aruco@)
  SET(aruco_DIR @aruco_DIR@)
  FIND_PACKAGE(aruco REQUIRED NO_MODULE)
ENDIF()

IF(@PLUS_USE_LEAPMOTION@)
  SET(LeapSDK_DIR @LeapSDK_DIR@)
  FIND_PACKAGE(LeapSDK REQUIRED NO_MODULE)
ENDIF()

SET(PLUS_RENDERING_ENABLED @PLUS_RENDERING_ENABLED@)